package org.sy.lab.多线程基础._2_同步._2_ReentrantLock._1_创建锁;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Tick {
	
	private int num = 100;
	private Lock lock = new ReentrantLock();
	
	public void add() {
		lock.lock();
		num++;
		lock.unlock();
	}
	
	public void subtract() {
		lock.lock();
		num--;
		lock.unlock();
	}
	
	public int getNum() {
		return num;
	}
}
